package com.itmk.web.userInfo.service.impl;


import java.util.Base64;
import com.itmk.web.userInfo.entity.BasicInfo;
import com.itmk.web.userInfo.entity.EducationInfo;
import com.itmk.web.userInfo.entity.ForjobInfo;
import com.itmk.web.userInfo.mapper.UserInfoMapper;
import com.itmk.web.userInfo.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserInfoServiceImpl implements UserInfoService {

    //加盐
    private static final String B64 = "...ASEDcdthvfdWERVDDGHBfdrhgdjbfdr";

    @Autowired
    UserInfoMapper userInfoMaper;

    @Override
    public BasicInfo getBasicInfo(String uuid) {
        return userInfoMaper.getBasicInfo(uuid);
    }

    @Override
    public EducationInfo getEducationInfo(String uuid) {
        return userInfoMaper.getEducationInfo(uuid);
    }

    @Override
    public ForjobInfo getForJobInfo(String uuid) {
        return userInfoMaper.getForJobInfo(uuid);
    }

    @Override
    public Boolean updateBasicInfo(BasicInfo basicInfo,String uuid) {
        if (basicInfo.getPassword()!=null) {
            //对密码进行加密
            String pwCode = Base64.getEncoder().encodeToString((basicInfo.getPassword()+B64).getBytes());
            basicInfo.setPassword(pwCode);
            //再对User表进行修改密码
            userInfoMaper.updatePassword(pwCode,uuid);
        }
        return userInfoMaper.updateBasicInfo(basicInfo,uuid);
    }

    @Override
    public Boolean updateEdI(EducationInfo edi,String uuid) {
        return userInfoMaper.updateEducationInfo(edi,uuid);
    }

    @Override
    public Boolean updateFji(ForjobInfo fji, String uuid) {
        return userInfoMaper.updateForjobInfo(fji,uuid);
    }

    @Override
    public void updateLogo(String fileName, String uuid) {
        userInfoMaper.updateUserLogo(fileName,uuid);
    }
}
